home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Garbo
/
Garbo.cdr
/
mac
/
unix
/
textmstr.shr
/
tm.hqx
/
Source Code ƒ
/
P
/
PD_Help_window_2.c
< prev
next >
Wrap
Text File
|
1991-05-09
|
9KB
|
264 lines
/* PD_Help_window_2 */
/* File name: Help_window_2 */
/* Function: Handle a modal dialog */
/* History: 5/9/91 Original by Prototyper 3.0 */
#include "PCommonTextMaster.h" /* Common */
#include "Common_TextMaster.h" /* Common */
#include "PUtils_TextMaster.h" /* General Utilities */
#include "Utils_TextMaster.h" /* General Utilities */
#include "PD_Help_window_2.h" /* This file */
#include "Help_window_2.h" /* The user file */
/* ======================================================= */
static Boolean ExitDialog; /* Flag used to exit the Dialog */
static Point MyPt; /* Current list selection point */
static OSErr MyErr; /* OS error returned */
static DialogPtr GetSelection; /* Pointer to this dialog */
static GrafPtr SavedPort; /* Previous grafport */
/* Prototypes */
/* Filter routine for modal dialog routine */
static pascal Boolean MyFilter (DialogPtr theDialog ,EventRecord *theEvent,short *itemHit);
/* This is an update routine for non-controls in the dialog */
/* This is executed after the dialog is uncovered by an alert */
static void Refresh_Dialog(void); /* Refresh the dialogs non-controls */
/* ======================================================= */
/* Initialize the modal dialog, globals and call users routine */
void I_PD_Help_window_2()
{
Rect tempRect; /* Temporary rectangle */
short DType; /* Type of dialog item */
short Index; /* For looping */
Handle DItem; /* Handle to the dialog item */
ControlHandle CItem, CTempItem; /* Control handle */
Str255 sTemp; /* Get text entered, temp holding */
short itemHit; /* Get selection */
short temp; /* Get selection, temp holding */
D_Init_Help_window_2();
} /* End of procedure */
/* ======================================================= */
/* Filter routine for dialog events */
static pascal Boolean MyFilter (theDialog ,theEvent,itemHit)
DialogPtr theDialog;
EventRecord *theEvent;
short *itemHit;
{
Point MyPt; /* Current list selection point */
Rect tempRect; /* Temporary rectangle */
short DType; /* Type of dialog item */
Handle DItem; /* Handle to the dialog item */
ControlHandle CItem; /* Control handle */
short chCode; /* Key entered */
long LTemp; /* Used for time delay */
char MyCmdKey; /* The command key */
Boolean CmdDown; /* Flag for command key used */
Boolean valMyFilter; /* Value to return */
valMyFilter = D_Filter_Help_window_2(theDialog, theEvent, itemHit);/* Call the user routine */
if ((theEvent->what == updateEvt) && ((WindowPtr)theEvent->message == theDialog))/* Only do on an update */
{
BeginUpdate(theDialog); /* Start the update */
DrawDialog(theDialog); /* Draw the controls */
valMyFilter = TRUE; /* Pass out this special itemHit number */
*itemHit = 32000; /* Our special ID */
}
if (theEvent->what == mouseDown) /* Only do on a mouse click */
{
MyPt = theEvent->where; /* Get the point where the mouse was clicked */
GlobalToLocal(&MyPt); /* Convert global to local */
}
if (theEvent->what == keyDown)
{
chCode = theEvent->message & charCodeMask; /* Get character */
MyCmdKey = (char)chCode; /* Change to ASCII */
CmdDown = ((theEvent->modifiers / cmdKey) != 0); /* Get command key state */
if (CmdDown == TRUE) /* Do if command key was down */
{
if ((MyCmdKey == 'x') || (MyCmdKey == 'X'))
{
DlgCut(theDialog);
valMyFilter = TRUE;
}
else if ((MyCmdKey =='c') || (MyCmdKey == 'C'))
{
DlgCopy(theDialog);
valMyFilter = TRUE;
}
else if ((MyCmdKey =='v') || (MyCmdKey == 'V'))
{
DlgPaste(theDialog);
valMyFilter = TRUE;
}
}
else if ((chCode == 13) || (chCode == 3)) /* CR or Enter */
{
valMyFilter = TRUE; /* Flag we got a hit */
*itemHit = 1; /* Default for CR */
GetDItem (theDialog ,*itemHit, &DType, &DItem, &tempRect);/* Get the item */
if (DType == (ctrlItem + btnCtrl)) /* If a button then ... */
{
CItem = (ControlHandle)DItem; /* Make it a controlhandle */
HiliteControl(CItem, 10); /* Hilite it */
LTemp = TickCount() + 15; /* Flash the button for 1/4 second */
do
{}
while (LTemp > TickCount());
HiliteControl(CItem, 0); /* UnHilite it */
}
}
}
return(valMyFilter);
}
/* ======================================================= */
/* ======================================================= */
/* This is an update routine for non-controls in the dialog */
/* This is executed after the dialog is uncovered by an alert */
static void Refresh_Dialog() /* Refresh the dialogs non-controls */
{
Rect rTempRect; /* Temp rectangle used for drawing */
short DType; /* Type of dialog item */
Handle DItem; /* Handle to the dialog item */
ControlHandle CItem; /* Control handle */
SetPort(GetSelection); /* Point to our dialog window */
rTempRect = tempRect; /* Save the current contents of tempRect */
GetDItem(GetSelection,Res_Dlg_OK3,&DType,&DItem,&tempRect);/* Get the item handle */
PenSize(3, 3); /* Change pen to draw thick default outline */
InsetRect(&tempRect, -4, -4); /* Draw outside the button by 1 pixel */
FrameRoundRect(&tempRect, 16, 16); /* Draw the outline */
PenSize(1, 1); /* Restore the pen size to the default value */
/* Draw a line, Drawn line1 */
MoveTo(10,30); /* Horz,vert, Move to starting position */
LineTo(179,30); /* Horz,vert, Draw to the ending position */
/* Draw a line, Drawn line2 */
MoveTo(10,35); /* Horz,vert, Move to starting position */
LineTo(179,35); /* Horz,vert, Draw to the ending position */
/* Draw a line, Drawn line3 */
MoveTo(10,155); /* Horz,vert, Move to starting position */
LineTo(434,155); /* Horz,vert, Draw to the ending position */
/* Draw a line, Drawn line3-4 */
MoveTo(10,80); /* Horz,vert, Move to starting position */
LineTo(434,80); /* Horz,vert, Draw to the ending position */
tempRect = rTempRect; /* Restore the current contents of tempRect */
D_Refresh_Help_window_2(GetSelection); /* Call user refresh routine */
}
/* ======================================================= */
void PD_Help_window_2()
{
Rect tempRect; /* Temporary rectangle */
short DType; /* Type of dialog item */
short Index; /* For looping */
Handle DItem; /* Handle to the dialog item */
ControlHandle CItem; /* Control handle */
ControlHandle CTempItem; /* temp Control handle */
Str255 sTemp; /* Get text entered, temp holding */
short itemHit; /* Get selection */
short temp; /* Get selection, temp holding */
GetPort(&SavedPort); /* Get the previous grafport */
GetSelection = GetNewDialog(Res_D_Help_window_2, NIL, (Ptr)-1);/* Bring in the dialog resource */
ShowWindow(GetSelection); /* Open a dialog box */
SelectWindow(GetSelection); /* Lets see it */
SetPort(GetSelection); /* Prepare to add conditional text */
/* Setup initial conditions */
Refresh_Dialog(); /* Draw any Lists, lines, or rectangles */
ExitDialog = FALSE; /* Do not exit dialog handle loop yet */
D_Setup_Help_window_2(GetSelection); /* Call user Dialog setup routine */
do /* Start of dialog handle loop */
{
ModalDialog(&MyFilter, &itemHit); /* Wait until an item is hit */
if (itemHit == 32000) /* Check for update */
{
Refresh_Dialog(); /* Draw any Lists, lines, or rectangles*/
EndUpdate(GetSelection); /* End of the update*/
}
else
{
GetDItem(GetSelection, itemHit, &DType, &DItem, &tempRect);/* Get item information */
CItem = (ControlHandle)DItem; /* Get the control handle */
}
D_Hit_Help_window_2(GetSelection,itemHit,&ExitDialog);/* Let user handle the item hit */
/* Handle it real time */
if (itemHit ==Res_Dlg_OK3) /* Handle the Button being pressed */
{
ExitDialog = TRUE; /* Close this dialog, exit */
}
if (itemHit ==Res_Dlg_Previous) /* Handle the Button being pressed */
{
Add_UserEvent(UserEvent_Open_Window,Res_D_Help_window,0,0,NIL);/* Open a modal dialog */
ExitDialog = TRUE; /* Close this dialog, exit */
}
}
while (ExitDialog == FALSE); /* Handle dialog items until exit selected */
D_Exit_Help_window_2(GetSelection); /* Exiting the modal dialog */
SetPort(SavedPort); /* Restore the previous grafport */
DisposDialog(GetSelection); /* Flush the dialog out of memory */
} /* End of procedure */